package com.chen.corejava;

import java.util.Date;
import java.util.GregorianCalendar;

/**
 *@author：email: <a href="cyb@ewppay.com"> Administrator </a> 
 *@Date 2017-2-14 下午4:03:01 
 */

public class Employee implements Cloneable {
	private String name;
	
	private double salary;
	
	private Date hireDay;
	
	public Employee(String n,double s){
		name = n;
		salary = s;
		hireDay = new Date();
	}
	
	public Employee clone() throws CloneNotSupportedException{
		Employee cloned = (Employee) super.clone();
		cloned.hireDay = (Date) hireDay.clone();
		return cloned;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public double getSalary() {
		return salary;
	}

	public void setSalary(double salary) {
		this.salary = salary;
	}

	public Date getHireDay() {
		return hireDay;
	}

	public void setHireDay(Date hireDay) {
		this.hireDay = hireDay;
	}
	
	public void setHireDay(int year,int month,int day){
		Date newHireDay = new GregorianCalendar(year, month - 1, day).getTime();
		hireDay.setTime(newHireDay.getTime());
	}
	
	public void raiseSalary(double byPercent){
		double raise = salary * byPercent / 100;
		salary += raise;
	}

	@Override
	public String toString() {
		return this.name+","+this.salary+","+this.hireDay;
	}
	
	
}
